package com.probiz.estore.common.model.product.base;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.common.model.product.Product;
import com.probiz.estore.common.model.product.ProductReview;
import com.probiz.estore.common.model.product.ReviewVote;
import com.probiz.estore.common.model.system.AppUser;
import com.probiz.estore.core.model.BaseObject;

/**
 * ProductReview Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class ProductReviewTbl extends BaseObject implements Serializable {

    protected Integer productReviewId;
	protected String customerName;
	protected String subject;
	protected String message;
	protected String remoteIp;
	protected String address;
	protected Integer givenPoint;
	protected Date givenTime;
	protected Integer usefulCount;
	protected Integer unusefulCount;
	protected Date createTime;
	protected Date updateTime;
	protected Short status;
	protected Product product;
	/**
	 * 评论客户，当前台发表评论时，就为客户，后台为管理员
	 */
	protected AppUser customer;
	/**
	 * 赠送者
	 */
	protected AppUser grantor;
	
	protected Set productRateValues = new HashSet();
	protected Set<ReviewVote> reviewVotes = new HashSet<ReviewVote>();

	protected ProductReview parent;
	protected Integer replyCount;
	protected Integer onShowReplyCount;
	protected Integer sortOrder;
	protected Short isRead;
	protected BigDecimal score;
	
	/**
	 * Default Empty Constructor for class ProductReview
	 */
	public ProductReviewTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class ProductReview
	 */
	public ProductReviewTbl (
		 Integer in_productReviewId
        ) {
		this.setProductReviewId(in_productReviewId);
    }

	
	public com.probiz.estore.common.model.product.Product getProduct () {
		return product;
	}	
	
	public void setProduct (com.probiz.estore.common.model.product.Product in_product) {
		this.product = in_product;
	}
	

	public AppUser getCustomer() {
		return customer;
	}

	public void setCustomer(AppUser customer) {
		this.customer = customer;
	}

	public java.util.Set getProductRateValues () {
		return productRateValues;
	}	
	
	public void setProductRateValues (java.util.Set in_productRateValues) {
		this.productRateValues = in_productRateValues;
	}

	
    

	public Set<ReviewVote> getReviewVotes() {
		return reviewVotes;
	}

	public void setReviewVotes(Set<ReviewVote> reviewVotes) {
		this.reviewVotes = reviewVotes;
	}

	/**
	 * 	 * @return Integer
     * @hibernate.id column="productReviewId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getProductReviewId() {
		return this.productReviewId;
	}
	
	/**
	 * Set the productReviewId
	 */	
	public void setProductReviewId(Integer aValue) {
		this.productReviewId = aValue;
	}	

	/**
	 * 	 * @return Integer
	 */
	public Integer getProductId() {
		return this.getProduct()==null?null:this.getProduct().getProductId();
	}
	
	/**
	 * Set the productId
	 */	
	public void setProductId(Integer aValue) {
	    if (aValue==null) {
	    	product = null;
	    } else {
	    	product = new com.probiz.estore.common.model.product.Product(aValue);
	        product.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	/**
	 */
	public Integer getCustomerId() {
		return this.getCustomer()==null?null:this.getCustomer().getAppuserId();
	}
	
	/**
	 * Set the managerId
	 */	
	public void setCustomerId(Integer aValue) {
	    if (aValue==null) {
	    	customer = null;
	    } else {
	    	customer = new AppUser(aValue);
	    	customer.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	
	

	public ProductReview getParent() {
		return parent;
	}

	public void setParent(ProductReview parent) {
		this.parent = parent;
	}
	
	
	public Integer getParentId() {
		return this.getParent()==null?null:this.getParent().getProductReviewId();
	}
	
	public void setParentId(Integer aValue) {
	    if (aValue==null) {
	    	parent = null;
	    } else {
	    	parent = new ProductReview(aValue);
	    	parent.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	/**
	 * @hibernate.property column="customerName" type="java.lang.String" length="64" not-null="false" unique="false"
	 */
	public String getCustomerName() {
		return this.customerName;
	}
	
	/**
	 * Set the customerName
	 */	
	public void setCustomerName(String aValue) {
		this.customerName = aValue;
	}	

	/**
	 * 发表评论的主题	 * @return String
	 * @hibernate.property column="subject" type="java.lang.String" length="128" not-null="false" unique="false"
	 */
	public String getSubject() {
		return this.subject;
	}
	
	/**
	 * Set the subject
	 */	
	public void setSubject(String aValue) {
		this.subject = aValue;
	}	

	/**
	 * 评论内容（消息）	 * @return String
	 * @hibernate.property column="message" type="java.lang.String" length="2048" not-null="true" unique="false"
	 */
	public String getMessage() {
		return this.message;
	}
	
	/**
	 * Set the message
	 * @spring.validator type="required"
	 */	
	public void setMessage(String aValue) {
		this.message = aValue;
	}	

	/**
	 * 	 * @return String
	 * @hibernate.property column="remoteIp" type="java.lang.String" length="32" not-null="true" unique="false"
	 */
	public String getRemoteIp() {
		return this.remoteIp;
	}
	
	/**
	 * Set the remoteIp
	 * @spring.validator type="required"
	 */	
	public void setRemoteIp(String aValue) {
		this.remoteIp = aValue;
	}	
	

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="givenPoint" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getGivenPoint() {
		return this.givenPoint;
	}
	
	/**
	 * Set the givenPoint
	 */	
	public void setGivenPoint(Integer aValue) {
		this.givenPoint = aValue;
	}	

	/**
	 * 	 * @return java.util.Date
	 * @hibernate.property column="givenTime" type="java.util.Date" length="0" not-null="false" unique="false"
	 */
	public java.util.Date getGivenTime() {
		return this.givenTime;
	}
	
	/**
	 * Set the givenTime
	 */	
	public void setGivenTime(java.util.Date aValue) {
		this.givenTime = aValue;
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="usefulCount" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getUsefulCount() {
		return this.usefulCount;
	}
	
	/**
	 * Set the usefulCount
	 */	
	public void setUsefulCount(Integer aValue) {
		this.usefulCount = aValue;
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="unusefulCount" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getUnusefulCount() {
		return this.unusefulCount;
	}
	
	/**
	 * Set the unusefulCount
	 */	
	public void setUnusefulCount(Integer aValue) {
		this.unusefulCount = aValue;
	}	


	/**
	 * 	 * @return java.util.Date
	 * @hibernate.property column="createTime" type="java.util.Date" length="0" not-null="true" unique="false"
	 */
	public java.util.Date getCreateTime() {
		return this.createTime;
	}
	
	/**
	 * Set the createTime
	 * @spring.validator type="required"
	 */	
	public void setCreateTime(java.util.Date aValue) {
		this.createTime = aValue;
	}	

	/**
	 * 	 * @return java.util.Date
	 * @hibernate.property column="updateTime" type="java.util.Date" length="0" not-null="true" unique="false"
	 */
	public java.util.Date getUpdateTime() {
		return this.updateTime;
	}
	
	/**
	 * Set the updateTime
	 * @spring.validator type="required"
	 */	
	public void setUpdateTime(java.util.Date aValue) {
		this.updateTime = aValue;
	}	
	


	public Integer getReplyCount() {
		return replyCount;
	}

	public void setReplyCount(Integer replyCount) {
		this.replyCount = replyCount;
	}
	
	

	public Integer getOnShowReplyCount() {
		return onShowReplyCount;
	}

	public void setOnShowReplyCount(Integer onShowReplyCount) {
		this.onShowReplyCount = onShowReplyCount;
	}
	

	public Integer getSortOrder() {
		return sortOrder;
	}

	public void setSortOrder(Integer sortOrder) {
		this.sortOrder = sortOrder;
	}

	public Short getIsRead() {
		return isRead;
	}

	public void setIsRead(Short isRead) {
		this.isRead = isRead;
	}

	public BigDecimal getScore() {
		return score;
	}

	public void setScore(BigDecimal score) {
		this.score = score;
	}

	/**
	 * @return Short
	 * @hibernate.property column="status" type="java.lang.Short" length="5" not-null="true" unique="false"
	 */
	public Short getStatus() {
		return this.status;
	}
	
	/**
	 * Set the status
	 * @spring.validator type="required"
	 */	
	public void setStatus(Short aValue) {
		this.status = aValue;
	}	

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof ProductReviewTbl)) {
			return false;
		}
		ProductReviewTbl rhs = (ProductReviewTbl) object;
		return new EqualsBuilder()
				.append(this.productReviewId, rhs.productReviewId)
				.append(this.customerName, rhs.customerName)
				.append(this.subject, rhs.subject)
				.append(this.message, rhs.message)
				.append(this.remoteIp, rhs.remoteIp)
				.append(this.givenPoint, rhs.givenPoint)
				.append(this.givenTime, rhs.givenTime)
				.append(this.usefulCount, rhs.usefulCount)
				.append(this.unusefulCount, rhs.unusefulCount)
				.append(this.createTime, rhs.createTime)
				.append(this.updateTime, rhs.updateTime)
				.append(this.status, rhs.status)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.productReviewId) 
				.append(this.customerName) 
				.append(this.subject) 
				.append(this.message) 
				.append(this.remoteIp) 
				.append(this.givenPoint) 
				.append(this.givenTime) 
				.append(this.usefulCount) 
				.append(this.unusefulCount) 
				.append(this.createTime) 
				.append(this.updateTime) 
				.append(this.status) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("productReviewId", this.productReviewId) 
				.append("customerName", this.customerName) 
				.append("subject", this.subject) 
				.append("message", this.message) 
				.append("remoteIp", this.remoteIp) 
				.append("givenPoint", this.givenPoint) 
				.append("givenTime", this.givenTime) 
				.append("usefulCount", this.usefulCount) 
				.append("unusefulCount", this.unusefulCount) 
				.append("createTime", this.createTime) 
				.append("updateTime", this.updateTime) 
				.append("status", this.status) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "productReviewId";
	}
	
	/**
	 * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return productReviewId;
	}

	public void setGrantor(com.probiz.estore.common.model.system.AppUser grantor) {
		this.grantor = grantor;
	}

	public com.probiz.estore.common.model.system.AppUser getGrantor() {
		return grantor;
	}
	
	public Integer getGrantorId() {
		return this.getGrantor()==null?null:this.getGrantor().getAppuserId();
	}
	
	/**
	 * Set the managerId
	 */	
	public void setGrantorId(Integer aValue) {
	    if (aValue==null) {
	    	grantor = null;
	    } else {
	    	grantor = new com.probiz.estore.common.model.system.AppUser(aValue);
	    	grantor.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}
}